package com.project.aiqicha;

import cn.hutool.core.net.URLEncoder;
import cn.hutool.core.util.ReUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.project.frame.common.annotation.LogIgnore;
import com.project.frame.common.controller.BaseController;
import com.project.frame.common.model.BaseResp;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Map;

/**
 * desc
 *
 * @author cjq
 * @date 2023-08-29
 */
@RestController
@RequestMapping("/aiqicha")
@Slf4j
public class AiqichaController extends BaseController {

    @Autowired
    AiqichaService aiqichaService;

    @PostMapping(value = "search")
    @LogIgnore
    public BaseResp search(@RequestBody String json)
            throws Exception {
        String msg = "未查询到数据（请完善税号和开业日期后重试，查无数据，请向技术人员反馈）";
        try{
            JSONObject obj = JSONObject.parseObject(json);
            String name = obj.getString("name");
            String code = obj.getString("code");
            BaseResp resp = aiqichaService.search(name,code );
            /*if(resp.isSuccess()==false){
                resp.setMsg(msg);
            }*/
            return resp;
        }catch(Exception e){
            e.printStackTrace();
            return BaseResp.renderFail(AiqichaCode.CODE_ERR,"企业查询服务异常，请向技术人员反馈");
        }

    }


}
